Skip to content
This repository has been archived by the owner on Oct 8, 2024. It is now read-only.

Add traefik_route to serve tracing endpoints through ingress if it exists #94

Merged
merged 19 commits into from
May 3, 2024

Conversation

mmkay
Copy link
Contributor

@mmkay mmkay commented Apr 25, 2024

Issue

Tempo receiver endpoints were not accessible over traefik as they are bound to different ports. Fixes #82

Solution

Use traefik_route with changes introduced in traefik-k8s-operator#325 to define ports traefik needs to open.
Also fix creating URLs for tracing consumers that use external_url - scheme and port were missing from the created url.

Context

This change is needed for cross-model traces to work. They cannot access internal endpoints of a different k8s cluster . No traces were also coming from machine models.

Testing Instructions

Run the following bundle and verify endpoints (example, port 3200, /metrics, port 4318 (expected prometheus metrics), /v1/traces (expected HTTP code 405)) are accessible on traefik's external IP.

bundle: kubernetes
applications:
  tempo:
    charm: local:tempo-k8s-1
    scale: 1
    constraints: arch=amd64
    storage:
      data: kubernetes,1,1024M
  traefik-k8s:
    charm: traefik-k8s
    channel: latest/edge
    revision: 184
    base: [email protected]/stable
    resources:
      traefik-image: 159
    scale: 1
    constraints: arch=amd64
    storage:
      configurations: kubernetes,1,1024M
relations:
- - tempo:tracing
  - traefik-k8s:tracing
- - traefik-k8s:traefik-route
  - tempo:ingress

Release Notes

@mmkay mmkay mentioned this pull request Apr 25, 2024
@mmkay mmkay changed the title [WIP] Add traefik_route to serve tracing endpoints through ingress if it exists Add traefik_route to serve tracing endpoints through ingress if it exists Apr 26, 2024
@mmkay mmkay marked this pull request as ready for review April 26, 2024 09:08
@mmkay mmkay requested a review from michaeldmitry April 26, 2024 09:08
Copy link
Contributor

@PietroPasotti PietroPasotti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! However I'd really like to see some tests.
At least a couple of unittests for databag contents and endpoints based on whether there is an ingress relation.

Secondly, wondering if we should be renaming the 'ingress' endpoint to traefik-route to follow the convention of having endpoints and interfaces similarly named.
Also, if some day we choose to provide this kind of multi-route, hybrid ingress via traefik and upgrade the ingress relation accordingly, we can swap them out without the ingress name being taken by something that isn't quite ingress.

src/charm.py Outdated Show resolved Hide resolved
src/charm.py Outdated Show resolved Hide resolved
src/charm.py Outdated Show resolved Hide resolved
src/charm.py Outdated Show resolved Hide resolved
src/charm.py Outdated Show resolved Hide resolved
src/charm.py Outdated Show resolved Hide resolved
src/charm.py Outdated Show resolved Hide resolved
charmcraft.yaml Show resolved Hide resolved
src/charm.py Show resolved Hide resolved
src/charm.py Show resolved Hide resolved
src/charm.py Show resolved Hide resolved
@mmkay
Copy link
Contributor Author

mmkay commented Apr 30, 2024

@PietroPasotti: regarding this part:

Secondly, wondering if we should be renaming the 'ingress' endpoint to traefik-route to follow the convention of having endpoints and interfaces similarly named.
Also, if some day we choose to provide this kind of multi-route, hybrid ingress via traefik and upgrade the ingress relation accordingly, we can swap them out without the ingress name being taken by something that isn't quite ingress.

I don't mind changing the interface name but I was basing the current approach on that Grafana also uses ingress in the same manner:

https://github.com/canonical/grafana-k8s-operator/blob/main/charmcraft.yaml#L54

As it was the only o11y charm that uses traefik_route that I know of, I chose the same pattern as it is fairly transparent to the charm users - they want to relate to Traefik and they're (mostly) used that the protocol they would use is named "ingress". I can however change that if you think having ingress free for future use is useful :)

@mmkay mmkay requested a review from PietroPasotti April 30, 2024 21:24
Copy link
Contributor

@PietroPasotti PietroPasotti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking good! a few things that we need to check :)

tests/scenario/test_ingressed_tracing.py Outdated Show resolved Hide resolved
tests/scenario/test_tracing_requirer.py Outdated Show resolved Hide resolved
src/charm.py Outdated Show resolved Hide resolved
src/charm.py Outdated Show resolved Hide resolved
src/charm.py Outdated Show resolved Hide resolved
Copy link
Contributor

@PietroPasotti PietroPasotti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mainly the provider endpoint api needs a final touch IMHO

charmcraft.yaml Outdated Show resolved Hide resolved
src/charm.py Outdated Show resolved Hide resolved
Copy link
Contributor

@PietroPasotti PietroPasotti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one final typing suggestion, then we can go!
Only concern I'm left with is the situation where Traefik has TLS, tempo doesn't: external url will be https, internal one will be http.

Will ingestion work via both?

Once you're convinced this is fine, we're good :)

lib/charms/tempo_k8s/v2/tracing.py Outdated Show resolved Hide resolved
Copy link
Contributor

@PietroPasotti PietroPasotti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's something wrong with http/https and ingress after all

lib/charms/tempo_k8s/v2/tracing.py Show resolved Hide resolved
Copy link
Contributor

@PietroPasotti PietroPasotti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what an emotional rollercoaster

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make ingestion endpoints available over ingress
3 participants